
cc.Class({
    extends: cc.Component,

    properties: {
        ui_label : cc.Label,
    },

    init(msg,type){
        var self = this;
        this.ui_label.string = msg;
        let color = cc.Color.WHITE;

        if (type == Global.Code.SUCCESS){
            color = cc.Color.GREEN;
        }
        
        if (type == Global.Code.FAIL){
            color = cc.Color.RED;
        }

        this.ui_label.node.color = color;
        this.node.setPosition(new cc.Vec2(cc.winSize.width/2,cc.winSize.height/2))

        setTimeout(function() {
            if (self.node){
                self.node.opacity = 255;
                let t = cc.tween(self.node)
                .to(0.3, { position:cc.v2(self.node.x, self.node.y+150),opacity:0 })
                .call(() => {
                    self.node.removeFromParent();
                }).start();
            }
        }, 1500);
    }
});
